<template>
  <div>
    <div class="bookShdow" ref="bookbox">
      <div v-for="item in data" :key="item.id">
        <van-divider v-if="item.top" @click.stop
          >{{ item.top.substr(0, 4) }}年{{
            item.top.substr(5, 2)
          }}月</van-divider
        >
        <div
          class="readItem"
          v-if="item.title"
          @click="$router.push(`/bookShadowContent/${item.id}`)"
        >
          <img :src="item.cover" alt="" />
          <div class="readInfo">
            <div>{{ item.title }}</div>
            <div>{{ item.subtitle }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getRead } from "@/api/find";
export default {
  name: "bookShadow",
  data() {
    return {
      data: [],
    };
  },
  created() {
    this.getBook(5, "2023-08");
    this.getLoading(5, "2022-10");
    this.getLoading(5, "2021-01");
  },
  methods: {
    async getBook(n, time) {
      const { data } = await getRead(n, time);
      this.data.unshift({ top: data[data.length - 1].maketime.substr(0, 10) });
      this.data.push(...data);
      console.log("书影数据", this.data);
    },
    async getLoading(n, time) {
      const { data } = await getRead(n, time);
      this.data.push({ top: data[data.length - 1].maketime.substr(0, 10) });
      this.data.push(...data);
      console.log("书影数据", this.data);
    },
    goShadow() {},
  },
};
</script>

<style lang="less" scoped>
.bookShdow {
  padding: 0 15px;
  padding-bottom: 50px;
  box-sizing: border-box;
  /*margin-top: 30px;*/
  background: rgba(255, 255, 255);
  .readItem {
    display: flex;
    margin: 10px 0;
    img {
      width: 50px;
      height: 50px;
      border-radius: 10px;
    }
    .readInfo {
      margin-left: 10px;
      & > div:nth-child(1) {
        font-size: 14px;
        color: #333333;
        margin-bottom: 5px;
      }
      & > div:nth-child(2) {
        font-size: 12px;
        color: #c3c3c3;
      }
    }
  }
}
</style>